#include "stdafx.h"
#include "PolygonTess.h"

namespace tge{

	PolyTriangle * CPolygonTess::s_pCurPolyTriangle = NULL;

	CPolygonTess::CPolygonTess(void)
	{
		s_pCurPolyTriangle = NULL;
	}

	CPolygonTess::~CPolygonTess(void)
	{
		int count = m_arrPolyTriangle.GetCount();
		for (int i = 0; i < count; i++){
			delete m_arrPolyTriangle[i];
		}
	}

	void CPolygonTess::Begin(int type)
	{
		s_pCurPolyTriangle = new PolyTriangle;
		s_pCurPolyTriangle->type = type;
		m_arrPolyTriangle.Add(s_pCurPolyTriangle);
	}

	void CPolygonTess::End()
	{
		s_pCurPolyTriangle = NULL;
	}

	void CPolygonTess::Vertex(GLdouble * pVertex)
	{
		Point3F pf;
		pf.data[0] = pVertex[0];
		pf.data[1] = pVertex[1];
		pf.data[2] = pVertex[2];
		s_pCurPolyTriangle->m_arrPoint.Add(pf);
	}
}